﻿using Nxg.Blog.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;

namespace Nxg.Blog.Web.Features
{
    public class ViewProjectionFactory : IViewProjectionFactory
    {
        private readonly IServiceProvider _serviceProvider;

        public ViewProjectionFactory(IServiceProvider provider)
        {
            _serviceProvider = provider;
        }
        public TOut Get<TIn, TOut>(TIn input)
        {
            var loadtr = _serviceProvider.GetService<IViewProjection<TIn, TOut>>();
            return loadtr.Project(input);
        }
    }
}
